import request from './axios'
import {DEFAULT_PAGENUM, DEFAULT_PAGESIZE} from "@/constent";

/**
 * 获取我的博客列表
 * @param pageSize
 */
export const getMyBlogList = (pageSize = 3,userId) => {
    return request({
        url:'/blog/getMyBlog',
        method:'get',
        params:{
            pageSize,
            userId
        }
    })
}

/**
 * 分页获取博客
 * @param data
 * @returns {*}
 */
const initData = {
    pageNum:DEFAULT_PAGENUM,
    pageSize:DEFAULT_PAGESIZE
};
export const getBlogList = (data = initData) => {
    return request.post('/blog/getBlogList',data)
}

/**
 * 添加评论
 * @param data
 * @returns {*}
 */
export const addComment = (data= {}) => {
    return request.post('/comment/addComment',data);
}

/**
 * 点赞功能
 * @param blogId
 * @returns {AxiosPromise}
 */
export const addNiu = (blogId) => {
    return request({
        url:'/blog/addNiu',
        method:'get',
        params:{
            blogId
        }
    })
}

/**
 * 发布博客
 * @param data
 * @returns {Promise<AxiosResponse<any>>}
 */
export const addBlog = (data) => {
    return request.post('/blog/addBlog',data);
}

/**
 * 用户自己删除博客
 * @param blogId
 * @returns {*}
 */
export const removeBlog = (blogId) => {
    return request({
        url:'/blog/removeBlog',
        method:'get',
        params:{
            blogId
        }
    })
}

/**
 * 管理员删除评论
 * @param commentId
 * @returns {*}
 */
export const removeComment = (commentId) => {
    return request({
        url:'/comment/removeComment',
        method:'get',
        params:{
            commentId
        }
    })
}

/**
 * 博客详情
 * @param blogId
 * @returns {*}
 */
export const getBlogDetail = (blogId) => {
    return request({
        url:'/blog/getBlogDetail',
        method:'get',
        params:{
            blogId
        }
    })
}
